EPOCH ?= 0
VERSION ?= dev

docker_registry = docker.wetranslate.huawei.com
docker_repository = wetranslate
image_base_name = api
image_tag = $(EPOCH).$(VERSION)
remote_image_name = $(docker_registry)/$(docker_repository)/$(image_base_name)
remote_image_full_name = $(remote_image_name):$(image_tag)

base_image_base_name=api-base
remote_base_image_name=$(docker_registry)/$(docker_repository)/$(base_image_base_name)
remote_base_image_full_name=$(remote_base_image_name):$(image_tag)

default: image

image:
	gradle clean build --info bootRepackage -Dprofile=prod
	docker build --rm -t $(remote_image_full_name) .

release:
	docker push $(remote_image_full_name)

	docker tag $(remote_image_full_name) $(remote_image_name):latest
	docker push $(remote_image_name):latest

base-image:
	docker build --rm -t $(remote_base_image_full_name) -f Dockerfile.base .

base-image-release:
	docker push $(remote_base_image_full_name)

	docker tag $(remote_base_image_full_name) $(remote_base_image_name):latest
	docker push $(remote_base_image_name):latest
